package com.plian.system.wrapper.pf;

import com.plian.system.dto.pf.LeaderSalaryDetailDTO;
import com.plian.system.entity.pf.LeaderSalaryDetail;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.pf.LeaderSalaryDetailVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * @description:
 * @author: gangan
 * @create: 2021-05-12 17:22
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface LeaderSalaryDetailWrapper extends BaseWrapper<LeaderSalaryDetail, LeaderSalaryDetailDTO, LeaderSalaryDetailVO> {

    /**
     * Entity转VO
     *
     * @param entity /
     * @return /
     */
    @Override
    @Mappings(value = {
            @Mapping(source = "rankId", target = "rankName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "jobNameId", target = "jobNameId", qualifiedByName = STR_NULL_TO_EMPTY),
            @Mapping(source = "jobNameId", target = "jobNameName", defaultValue = ""),
            @Mapping(target = "departmentName", expression = "java(cacheWrapperUtil.checkLeader(entity.getDepartmentNameId(), entity.getIsLeader()))")
    })
    LeaderSalaryDetailVO entityToVO(LeaderSalaryDetail entity);
}
